using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class ItemSupplierRelMap : EntityTypeConfiguration<ItemSupplierRel>
	{
		public ItemSupplierRelMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			// Table & Column Mappings
			this.ToTable("ItemSupplierRels");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.SupplierId).HasColumnName("SupplierId");
			this.Property(t => t.ItemId).HasColumnName("ItemId");
			this.Property(t => t.RecordStatus).HasColumnName("RecordStatus");
			this.Property(t => t.Prize).HasColumnName("Prize");

			// Relationships
			this.HasOptional(t => t.Item)
				.WithMany(t => t.ItemSupplierRels)
				.HasForeignKey(d => d.ItemId);
				
			this.HasOptional(t => t.Supplier)
				.WithMany(t => t.ItemSupplierRels)
				.HasForeignKey(d => d.SupplierId);
				
		}
	}
}

